Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Collections.Generic
Imports ASPNET.StarterKit.BusinessLogicLayer

Partial Public Class Project_List_aspx
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

        If Page.User.IsInRole("ProjectAdministrator") Then
            ProjectData.SortParameterName = "sortParameter"
            ProjectData.SelectMethod = "GetAllProjects"
            DisabledProjectData.SortParameterName = "sortParameter"
            DisabledProjectData.SelectMethod = "GetAllDisabledProjects"
        Else
            Dim wasFound As Boolean = False
            For Each parameter As Parameter In ProjectData.SelectParameters
                If parameter.Name = "userName" Then
                    wasFound = True
                End If
            Next parameter
            If (Not wasFound) Then
                Dim param As Parameter = New Parameter("userName", TypeCode.String, Page.User.Identity.Name)
                ProjectData.SelectParameters.Add(param)
            End If
            ProjectData.SortParameterName = "sortParameter"
            ProjectData.SelectMethod = "GetProjectsByManagerUserName"
            'TODO:Turn this off for Project Managers - Figure out how to turn the grid off so it does not throw errors
            ' For now we just hide it with the DisabledProjectView Panel
            DisabledProjectData.SortParameterName = "sortParameter"
            DisabledProjectData.SelectMethod = "GetAllDisabledProjects"
            DisabledProjectView.Visible = False
        End If

    End Sub

    Protected Sub Button_Click(ByVal sender As Object, ByVal args As EventArgs) Handles CreateProject.Click

        Server.Transfer("Project_Details.aspx")

    End Sub

    Protected Sub ListAllProjects_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles ListAllProjects.RowDeleting

        'e.Keys.Add("Id", ListAllProjects.Rows(e.RowIndex).Cells(0).Text)

    End Sub

End Class
